package com.example.describe.controller;


import com.example.classsify.pojo.Classsify;
import com.example.commons.result.CommonResult;
import com.example.commons.utils.PageResult;
import com.example.describe.pojo.Describe;
import com.example.describe.service.DescribeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class DescribeController {

    @Autowired
    DescribeService describeService;

    /**
     * @Author 小江
     * @Description //TODO 品牌全查
     * @Date 11:33 2022/11/16
     **/
    @GetMapping("/DescribeList")
    public CommonResult DescribeList(String brandName, Integer pageNum, Integer pageSize) {
        PageResult pageResult = new PageResult();
        pageResult.setPageNum(pageNum);
        pageResult.setPageSize(pageSize);
        PageResult pageResult1 = describeService.DescribeList(brandName, pageResult);
        return CommonResult.ok(pageResult1);
    }

    /**
     * @Author 小江
     * @Description //TODO 品牌 添加/修改
     * @Date 13:52 2022/11/16
     **/
    @PostMapping("/Describeinfo")
    public CommonResult Describeinfo (Describe describe, MultipartFile file) {

        int i = describeService.Describeinfo(describe,file);
        if (i > 0) {
            return CommonResult.ok("添加成功");

        } else {
            return CommonResult.fail(9999, "添加失败");
        }
    }

    /**
     * @Author 小江
     * @Description //TODO
     * @Date 14:50 2022/11/16
     **/
    @DeleteMapping("DescribeyDel")
    CommonResult Describe(Integer id){
        int i = describeService.Describe(id);
        if (i > 0) {
            return CommonResult.ok("删除用户信息成功");
        } else {
            return CommonResult.fail(9999, "删除用户信息失败");
        }
    }
    
}
